package voice;

import java.applet.Applet;
import java.applet.AudioClip;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Implements a player for voice messages
 * @author Alexandre, Cristovao, Raul, Rodolpho, Tales
 * @version 1.1
 * @milestone Number 2
 */
public class MessagePlayer {
	
	private AudioClip clip = null;
	
	/**
	 * Constructor 
	 * @param fileName of the voice message
	 * @throws MalformedURLException
	 */
	public MessagePlayer(String fileName) throws MalformedURLException {
		URL u = new URL("file", "localhost", fileName );
        clip = Applet.newAudioClip(u);
	}
	
	/**
	 * Plays the message
	 */
	public void playMessage(){
		clip.play();
	}
	
	/**
	 * Stop the playing of the message
	 */
	public void stopMessage(){
		clip.stop();
	}

}
